
test-convert1.o:     file format elf64-littleaarch64


Disassembly of section .text:

0000000000000000 <main>:
    char word;
	int num;
};  
  
int main()  
{  
   0:	a9bd7bfd 	stp	x29, x30, [sp, #-48]!
   4:	910003fd 	mov	x29, sp
    struct A1 x = {10, 'A'};
   8:	52800140 	mov	w0, #0xa                   	// #10
   c:	b90023a0 	str	w0, [x29, #32]
  10:	52800820 	mov	w0, #0x41                  	// #65
  14:	390093a0 	strb	w0, [x29, #36]
	struct A2 y = {'A', 10};
  18:	52800820 	mov	w0, #0x41                  	// #65
  1c:	390063a0 	strb	w0, [x29, #24]
  20:	52800140 	mov	w0, #0xa                   	// #10
  24:	b9001fa0 	str	w0, [x29, #28]

	/* 第一种方法 */
	//w.word = ((struct A2)x).a;	// error: conversion to non-scalar type requested

	/* 第二方法 */
	p = (struct A2 *)&x;
  28:	910083a0 	add	x0, x29, #0x20
  2c:	f90017a0 	str	x0, [x29, #40]
	w.word = p->word;
  30:	f94017a0 	ldr	x0, [x29, #40]
  34:	39400000 	ldrb	w0, [x0]
  38:	390043a0 	strb	w0, [x29, #16]

	printf("%d\n", w.word);		// 这种强制类型转换,把x当A2类型变量使用就通过这个p指针    output: 10
  3c:	394043a0 	ldrb	w0, [x29, #16]
  40:	2a0003e1 	mov	w1, w0
  44:	90000000 	adrp	x0, 0 <main>
  48:	91000000 	add	x0, x0, #0x0
  4c:	94000000 	bl	0 <printf>


	x.num = 1000;
  50:	52807d00 	mov	w0, #0x3e8                 	// #1000
  54:	b90023a0 	str	w0, [x29, #32]
	x.word = 'a';
  58:	52800c20 	mov	w0, #0x61                  	// #97
  5c:	390093a0 	strb	w0, [x29, #36]

	y.word = 'a';
  60:	52800c20 	mov	w0, #0x61                  	// #97
  64:	390063a0 	strb	w0, [x29, #24]
	y.num = 1000;
  68:	52807d00 	mov	w0, #0x3e8                 	// #1000
  6c:	b9001fa0 	str	w0, [x29, #28]
	
	//p = (struct A2 *)&x;
	w.word = p->word;
  70:	f94017a0 	ldr	x0, [x29, #40]
  74:	39400000 	ldrb	w0, [x0]
  78:	390043a0 	strb	w0, [x29, #16]

	printf("%d\n", w.word);		// output : -24 ; 因A2第一成员为char, 当大于255时，越界。
  7c:	394043a0 	ldrb	w0, [x29, #16]
  80:	2a0003e1 	mov	w1, w0
  84:	90000000 	adrp	x0, 0 <main>
  88:	91000000 	add	x0, x0, #0x0
  8c:	94000000 	bl	0 <printf>


	return 0;
  90:	52800000 	mov	w0, #0x0                   	// #0
}																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																									  
  94:	a8c37bfd 	ldp	x29, x30, [sp], #48
  98:	d65f03c0 	ret
